<template>
  <div class="app-container">
    <el-form
      ref="formDom"
      :model="model"
      :rules="fromField.rules"
      label-position="left"
      class="login-form"
    >
      <el-row :gutter="40">
        <el-col :span="8" v-for="item in fromField.field" :key="item.value">
          <el-form-item :label="item.paramName" :prop="item.paramKey">
            <el-input v-model="model[item.paramKey]" :placeholder="item.placeh" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="6">
          <el-form-item style="width:100%;">
            <el-button
              :loading="loading"
              size="medium"
              type="primary"
              style="width:100%;"
              @click.native.prevent="handleSubmit"
            >
              <span v-if="!loading">提交</span>
              <span v-else>提交...</span>
            </el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import { Notification } from "element-ui";
import G6Api from "@/api/g6/g6Api";
import FromData from "./formModel";
export default {
  name: "insertVehicle",
  data() {
    return {
      activeName: "first",
      loading: false,
      model: {
       vehRegisterMode: '0',
       emissionLevelType: '2'
      },
      fromField: FromData.insertVehicleForm
    };
  },
  computed: {},
  mounted() {
    //this.insertVehicleType = data
  },
  methods: {
    handleSubmit() {
      this.$refs.formDom.validate(valid => {
        if (valid) {
          G6Api.insertVehicleType({ strVehicleModel: this.model })
            .then(data => {
              Notification({
                message: "备案提交",
                type: "success",
                duration: 5 * 1000
              });
              this.loading = false;
            })
            .catch(() => {
              this.loading = false;
            });
        }
      });
    }
  }
};

</script>
